package com.example.udp.message;

import com.example.node.config.NodeConfig;
import com.example.node.utils.IdUtils;

import java.io.Serializable;

/*
 * @className: UdpMessage
 * @author: chentao
 * @date: 2025/10/25 下午5:45
 * @Version: 1.0
 * @description:
 */
public class UdpMessage implements Serializable {

    private String requestId;

    private Long requestTime;

    private Long senderId;

    private NodeConfig nodeConfig;

    public String getRequestId() {
        return requestId;
    }

    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }

    public Long getRequestTime() {
        return requestTime;
    }

    public void setRequestTime(Long requestTime) {
        this.requestTime = requestTime;
    }

    public Long getSenderId() {
        return senderId;
    }

    public void setSenderId(Long senderId) {
        this.senderId = senderId;
    }

    public NodeConfig getNodeConfig() {
        return nodeConfig;
    }

    public void setNodeConfig(NodeConfig nodeConfig) {
        this.nodeConfig = nodeConfig;
    }

    public UdpMessage(NodeConfig nodeConfig) {
        this.nodeConfig = nodeConfig;
        this.senderId = nodeConfig.getServerId();
        this.requestTime = System.currentTimeMillis();
        this.requestId = IdUtils.getId();
    }

    @Override
    public String toString() {
        return "UdpMessage{" +
                "requestId='" + requestId + '\'' +
                ", requestTime=" + requestTime +
                ", senderId=" + senderId +
                ", nodeConfig=" + nodeConfig +
                '}';
    }
}
